#! /usr/bin/env python
#coding=utf-8
import httplib
conn = httplib.HTTPConnection("www.python.org")
conn.request("HEAD","/index.html")
res = conn.getresponse()
print res.status, res.reason
data = res.read()
print len(data)
data == ''

def get(self):
    authorization = self.request.headers.get('Authorization', '')
    if authorization and authorization[:6] == 'Basic ':
        user, password = b64decode(authorization[6:]).split(':', 1)
        if user == 'admin' and password == 'fuckgfw':
            self.echo('hello, ' + user)
            return

    self.set_status(401)
    self.header['WWW-Authenticate'] = 'Basic realm="testrealm@keakon.cn"'
